<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-05-02
 * Time: 9:15
 */

namespace RedisClient;


class RedisClient
{
    public static $_instance = null;
    private static $config = [
        'host' => '127.0.0.1',
        'port' => 6379 ,
        'db' => 0,
    ];
    public function __construct(){return;}
    public static function init($custom_config = []){

        if(self::$_instance == null){
            $config = array_merge( self::$config ,$custom_config );
            self::$_instance = new \Redis();
            self::$_instance->connect($config['host'] ,$config['port']);
            self::$_instance->select($config['db']);
        }

        return self::$_instance;
    }

}